<?php
use yii\helpers\Url;
use yii\widgets\LinkPager;

?>

<?= $this->render('header'); ?>

<div id="member-service" class="container">

	<div class="mt20">
		<div class="cards">
			<div class="title">剩余疗程卡</div>
			<div class="clearfix">

				<?php foreach($beautycardList as $beautycard): ?>
					<span class="cards-list"><?= $beautycard['card_name'] ?>（<em class="red"><?= $beautycard['remain_times'] ?></em>/<?= $beautycard['total_times'] ?>）<?= $beautycard['is_give'] ? '<em class="red">赠送</em>' : '' ?></span>
				<?php endforeach; ?>

				<span class="cards-list" style="margin-top: 25px;"><a class="addCards remark btnBg"  style="height: 31px; line-height: 31px; padding: 0;" href="javascript:openPage();">点击添加疗程卡</a></span>
			</div>
		</div>
		<div class="allServe borB"><span>累计服务：<em class="red"><?= $totalCount ?></em>次</span></div>
		<div class="member-service-con mt20">
			<?php if(empty($list)){?>
			<table class="table table-bordered">
				<thead>
				<tr>
					<th width="230px;">美容师-服务项目</th>
					<th>服务日期</th>
					<th>服务时间</th>
					<th>预约时间</th>
					<th>房间</th>
					<th>服务记录</th>
				</tr>
				</thead>
				<tbody>
				<tr>
					<td colspan="6" align="center"><img src="<?=Yii::getAlias('@web/backend/img/nodata.gif');?>"></td>
				</tr>
				</tbody>
			</table>
			<?php }else{?>
			<table class="table table-bordered text-center">
				<thead>
				<tr>
					<th width="230px;">美容师-服务项目</th>
					<th>服务日期</th>
					<th>服务时间</th>
					<th>预约时间</th>
					<th>房间</th>
					<th>服务记录</th>
				</tr>
				</thead>
				<tbody>

				<?php foreach($list as $service): ?>
				<tr>
					<td>
						<div class="member-service-type clearfix">

							<?php foreach($service['extends'] as $extends): ?>
							<span><?= $extends['employee_name'] ?>-<?= $extends['beautycartd_name'] ?></span>
							<?php endforeach; ?>

						</div>
					</td>
					<?php $dateTime = explode(' ', $service['service_addtime']) ?>
					<td><?= $dateTime[0] ?></td>
					<td><?= substr($dateTime[1], 0, 5) . '-' . substr($service['service_endtime'], 11, 5) ?></td>
					<td><?= $service['make_time'] ?></td>
					<td><?= $service['room_name'] ?></td>
					<td><a class="btnMd" href="javascript:;" onclick="openRemark(<?= $service['service_id'] ?>)" style="width: 45px;height: 45px;background-color: #faa552;padding-top: 3px;"><img src="<?= Yii::getAlias('@web/backend/img/member/record_ico.png') ?>" alt=""/></a></td>
				</tr>
				<?php endforeach; ?>

				</tbody>
			</table>
			<?php }?>
			<div class="page">
				<?= LinkPager::widget([
					'pagination' => $page,
					// 'hideOnSinglePage' => true
				]); ?>
			</div>

		</div>
	</div>
</div>

	<script>
<?php $this->beginBlock('js_index') ?>

function openPage() {
	layer.open({
		type: 2,
		title: '添加疗程卡',
		maxmin: false,
		area: '50%',
		success: function(layero, index) {
			layer.iframeAuto(index);
			layer.style(index, {
				top: '200px'
			}); 
		},
		content: '<?=Url::to(['beautycard', 'id' => Yii::$app->request->get('id')])?>'
	});
}

/**
 * @param id 服务id
 */
function openRemark(id) {
	layer.open({
		type: 2,
		area: ['700px', '410px'],
		title:'',
		fix: true, //不固定
		maxmin: true,
		content: '<?= Url::to(['/business/server/remark']) ?>?u=/business/member/server&member_id=<?= Yii::$app->getRequest()->get('id') ?>&id=' + id
	});
}
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['js_index'], $this::POS_END); ?>
	</script>
